/*
 * @FilePath: /tads/server/config/gorm_postgres.go
 * @Author: wnina0x0
 * @Date: 2025-04-03 17:03:34
 * @Description:
 *
 * 版权信息 : 2025 by wnina0x0, All Rights Reserved.
 */
package config

type Postgres struct {
	Addr     string `mapstructure:"addr" json:"addr" yaml:"addr"`
	Port     string `mapstructure:"port" json:"port" yaml:"port"`
	DbName   string `mapstructure:"db-name" json:"db-name" yaml:"db-name"`
	Username string `mapstructure:"username" json:"username" yaml:"username"`
	Password string `mapstructure:"password" json:"password" yaml:"password"`
	Engine   string `mapstructure:"engine" json:"engine" yaml:"engine" default:"InnoDB"`
}

func (m *Postgres) Dsn() string {
	// return m.Username + ":" + m.Password + "@tcp(" + m.Addr + ":" + m.Port + ")/" + m.DbName
	return "host=" + m.Addr + " user=" + m.Username + " password=" + m.Password + " dbname=" + m.DbName + " port=" + m.Port + " sslmode=disable"
}
